/************************************************************************
 * File: boardslot.h                                                    *
 *                                                                      *
 * Copyright 2006, 2008 Colin Kern (colin.kern@gmail.com)               *
 *                                                                      *
 * This file is part of Profit.  Some previous versions were released   *
 * under the names Megacorp Mania and Acquire.                          *
 *                                                                      *
 * Profit is free software: you can redistribute it and/or modify       *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * any later version.                                                   *
 *                                                                      *
 * Profit is distributed in the hope that it will be useful,            *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with Profit.  If not, see <http://www.gnu.org/licenses/>.      *
 ************************************************************************/
#ifndef BOARD_SLOT_H
#define BOARD_SLOT_H

#include "globals.h"
#include <QWidget>

class Company;
class QLinearGradient;

class BoardSlot : public QWidget
{
	Q_OBJECT
	
    public:
		enum Highlight {None, LastPlaced, InHand};
		static const int Width = 40;
		static const int Height = 40;
		
        BoardSlot(int row, int column, QWidget *parent = 0);

        bool isPlaced() const;
        const Company *getOwner() const;
        bool isFlagged() const;
		bool isOwned() const;
		QSize sizeHint() const;

        void place(bool invisible = false);
        void remove(bool invisible = false);
        void setOwner(Company &company);
        void setOwner(Company *company);
        void flag();
        void unflag();
        Company *getOwner();
		void setHighlight(Highlight highlight);
		void setValid(bool valid = true);
		void setGradientStops();
		void setGradientColors();
		
	signals:
		void clicked(int row, int column);
		void hoverChanged(bool hover, int row, int column);
		
	public slots:
		void changePhase(Profit::Phase newPhase);
		
	protected:
		void paintEvent(QPaintEvent *event);
		void mousePressEvent(QMouseEvent *event);
		void enterEvent(QEvent *event);
		void leaveEvent(QEvent *event);
		void resizeEvent(QResizeEvent *event);

    private:
        bool m_isPlaced;
        Company* m_owner;
		Highlight m_highlight;
		Profit::Phase m_phase;
		bool m_hover;
        bool m_isFlagged;
		int m_row;
		int m_column;
		bool m_valid;
		QLinearGradient m_bottomGradient;
		QLinearGradient m_topGradient;
};

#endif

